package view;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import model.ArquivosDocumentos;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Documento extends javax.swing.JFrame {
	private JButton jButtonOK;
	private JLabel jLabelDocumento;
	private ImageIcon imagem = null;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public ImageIcon getImagem(){
		return imagem;
	}
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Documento inst = new Documento();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public Documento() {
		super();
		ArquivosDocumentos arquivos = new ArquivosDocumentos();
		imagem = arquivos.capturarDocumento();
		initGUI();
	}
	public Documento(String cpf) {
		super();
		ArquivosDocumentos arquivos = new ArquivosDocumentos();
		imagem = new ImageIcon();
		imagem.setImage(arquivos.abrirDocumento(cpf));
		initGUI();
	}	
	
	private void initGUI() {
		try {
			BorderLayout thisLayout = new BorderLayout();
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(thisLayout);
			{
				jButtonOK = new JButton();
				getContentPane().add(jButtonOK, BorderLayout.SOUTH);
				jButtonOK.setText("OK");
				jButtonOK.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
					dispose();						
					}
				});
			}
			{
				jLabelDocumento = new JLabel();
				getContentPane().add(jLabelDocumento, BorderLayout.CENTER);
				jLabelDocumento.setIcon(imagem);
			}
			pack();
			this.setSize(800, 600);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
